<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="订单编号" prop="fdOrderId">
        <el-input
          v-model="queryParams.fdOrderId"
          placeholder="请输入订单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="拟定线路编号" prop="fdPlannedRouteNumber">
        <el-input
          v-model="queryParams.fdPlannedRouteNumber"
          placeholder="请输入拟定线路编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="拟定线路名称" prop="fdPlannedRouteName">
        <el-input
          v-model="queryParams.fdPlannedRouteName"
          placeholder="请输入拟定线路名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="拟定车牌号码" prop="fdPlannedLicensePlateNumber">
        <el-input
          v-model="queryParams.fdPlannedLicensePlateNumber"
          placeholder="请输入拟定车牌号码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="核算编号" prop="fdAccountingNumber">
        <el-input
          v-model="queryParams.fdAccountingNumber"
          placeholder="请输入核算编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="报价编号" prop="fdQuotationNumber">
        <el-input
          v-model="queryParams.fdQuotationNumber"
          placeholder="请输入报价编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['ys:freightQuotationAccounting:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['ys:freightQuotationAccounting:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['ys:freightQuotationAccounting:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['ys:freightQuotationAccounting:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="info"
            plain
            icon="el-icon-upload2"
            size="mini"
            @click="handleImport"
        >导入</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="freightQuotationAccountingList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键编码" align="center" prop="id" />
      <el-table-column label="序号" align="center" prop="fdSerialNum" />
      <el-table-column label="组织名称" align="center" prop="fdOrganizationName" />
      <el-table-column label="组织代码" align="center" prop="fdOrganizationCode" />
      <el-table-column label="组织分类" align="center" prop="fdOrganizationCategory" />
      <el-table-column label="组织层级" align="center" prop="fdOrganizationLevel" />
      <el-table-column label="订单编号" align="center" prop="fdOrderId" />
      <el-table-column label="订单来源" align="center" prop="fdOrderSource" />
      <el-table-column label="发布单位" align="center" prop="fdPublishingUnit" />
      <el-table-column label="货源发布日期" align="center" prop="fdSourceReleaseDate" width="180"/>
      <el-table-column label="货源应到日期" align="center" prop="fdExpectedArrivalDate" width="180"/>
      <el-table-column label="货源紧急程度" align="center" prop="fdUrgencyLevelOfCargoSource" />
      <el-table-column label="货源发出地" align="center" prop="fdSourceDeparturePlace" />
      <el-table-column label="发出详细地址" align="center" prop="fdDetailedDepartureAddress" />
      <el-table-column label="货源目的地" align="center" prop="fdDestinationOfCargoSource" />
      <el-table-column label="目的详细地址" align="center" prop="fdDetailedDestinationAddress" />
      <el-table-column label="货源重量" align="center" prop="fdWeightOfCargoSource" />
      <el-table-column label="货源体积" align="center" prop="fdVolumeOfCargoSource" />
      <el-table-column label="拟定线路编号" align="center" prop="fdPlannedRouteNumber" />
      <el-table-column label="拟定线路名称" align="center" prop="fdPlannedRouteName" />
      <el-table-column label="中转地址" align="center" prop="fdTransferAddress" />
      <el-table-column label="拟定线路里程" align="center" prop="fdPlannedRouteMileage" />
      <el-table-column label="拟定车牌号码" align="center" prop="fdPlannedLicensePlateNumber" />
      <el-table-column label="车辆条形码" align="center" prop="fdVehicleBarcode" />
      <el-table-column label="载重质量" align="center" prop="fdLoadQuality" />
      <el-table-column label="车辆容积" align="center" prop="fdVehicleVolume" />
      <el-table-column label="车辆匹配顺序" align="center" prop="fdVehicleMatchingSequence" />
      <el-table-column label="核算编号" align="center" prop="fdAccountingNumber" />
      <el-table-column label="报价编号" align="center" prop="fdQuotationNumber" />
      <el-table-column label="核算类别" align="center" prop="fdAccountingCategory">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.accounting_category" :value="scope.row.fdAccountingCategory"/>
        </template>
      </el-table-column>
      <el-table-column label="过路费类别" align="center" prop="fdRoadTollCategory">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.toll_category" :value="scope.row.fdRoadTollCategory"/>
        </template>
      </el-table-column>
      <el-table-column label="车公里成本合计" align="center" prop="fdTotalCostPerVehicleKilometer" />
      <el-table-column label="吨公里成本合计" align="center" prop="fdTotalCostPerTonneKilometer" />
      <el-table-column label="立方成本合计" align="center" prop="fdTotalCostPerCubicMeter" />
      <el-table-column label="提货费" align="center" prop="fdPickUpFee" />
      <el-table-column label="装车费" align="center" prop="fdLoadingFee" />
      <el-table-column label="卸车费" align="center" prop="fdUnloadingFee" />
      <el-table-column label="风险管理费率" align="center" prop="fdRiskManagementFeeRate" />
      <el-table-column label="调整系数" align="center" prop="fdTzxs" />
      <el-table-column label="不含税报价" align="center" prop="fdTaxExcludedQuotation" />
      <el-table-column label="税率" align="center" prop="fdTaxRate" />
      <el-table-column label="税金" align="center" prop="fdTax" />
      <el-table-column label="含税报价" align="center" prop="fdHsbj" />
      <el-table-column label="核算人" align="center" prop="fdAccountant" />
      <el-table-column label="核算时间" align="center" prop="fdAccountingTime" width="180"/>
      <el-table-column label="备注" align="center" prop="fdRemark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['ys:freightQuotationAccounting:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['ys:freightQuotationAccounting:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改运费报价核算对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="序号" prop="fdSerialNum">
              <el-input v-model="form.fdSerialNum" placeholder="请输入序号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="组织名称" prop="fdOrganizationName">
              <el-input v-model="form.fdOrganizationName" placeholder="请输入组织名称" @focus="selectOrganization()"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="组织代码" prop="fdOrganizationCode">
              <el-input v-model="form.fdOrganizationCode" placeholder="请输入组织代码" @focus="selectOrganization()"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="组织层级" prop="fdOrganizationLevel">
              <el-input v-model="form.fdOrganizationLevel" placeholder="请输入组织层级" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单编号" prop="fdOrderId">
              <el-input v-model="form.fdOrderId" placeholder="请输入订单编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单来源" prop="fdOrderSource">
              <el-input v-model="form.fdOrderSource" placeholder="请输入订单来源" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发布单位" prop="fdPublishingUnit">
              <el-input v-model="form.fdPublishingUnit" placeholder="请输入发布单位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="货源发布日期" prop="fdSourceReleaseDate">
              <el-date-picker clearable
                v-model="form.fdSourceReleaseDate"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择货源发布日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="货源应到日期" prop="fdExpectedArrivalDate">
              <el-date-picker clearable
                v-model="form.fdExpectedArrivalDate"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择货源应到日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="货源紧急程度" prop="fdUrgencyLevelOfCargoSource">
              <el-input v-model="form.fdUrgencyLevelOfCargoSource" placeholder="请输入货源紧急程度" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="货源发出地" prop="fdSourceDeparturePlace">
              <el-input v-model="form.fdSourceDeparturePlace" placeholder="请输入货源发出地" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发出详细地址" prop="fdDetailedDepartureAddress">
              <el-input v-model="form.fdDetailedDepartureAddress" placeholder="请输入发出详细地址" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="货源目的地" prop="fdDestinationOfCargoSource">
              <el-input v-model="form.fdDestinationOfCargoSource" placeholder="请输入货源目的地" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="目的详细地址" prop="fdDetailedDestinationAddress">
              <el-input v-model="form.fdDetailedDestinationAddress" placeholder="请输入目的详细地址" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="货源重量" prop="fdWeightOfCargoSource">
              <el-input v-model="form.fdWeightOfCargoSource" placeholder="请输入货源重量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="货源体积" prop="fdVolumeOfCargoSource">
              <el-input v-model="form.fdVolumeOfCargoSource" placeholder="请输入货源体积" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="拟定线路编号" prop="fdPlannedRouteNumber">
              <el-input v-model="form.fdPlannedRouteNumber" placeholder="请输入拟定线路编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="拟定线路名称" prop="fdPlannedRouteName">
              <el-input v-model="form.fdPlannedRouteName" placeholder="请输入拟定线路名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="中转地址" prop="fdTransferAddress">
              <el-input v-model="form.fdTransferAddress" placeholder="请输入中转地址" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="拟定线路里程" prop="fdPlannedRouteMileage">
              <el-input v-model="form.fdPlannedRouteMileage" placeholder="请输入拟定线路里程" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="拟定车牌号码" prop="fdPlannedLicensePlateNumber">
              <el-input v-model="form.fdPlannedLicensePlateNumber" placeholder="请输入拟定车牌号码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车辆条形码" prop="fdVehicleBarcode">
              <el-input v-model="form.fdVehicleBarcode" placeholder="请输入车辆条形码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="载重质量" prop="fdLoadQuality">
              <el-input v-model="form.fdLoadQuality" placeholder="请输入载重质量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车辆容积" prop="fdVehicleVolume">
              <el-input v-model="form.fdVehicleVolume" placeholder="请输入车辆容积" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车辆匹配顺序" prop="fdVehicleMatchingSequence">
              <el-input v-model="form.fdVehicleMatchingSequence" placeholder="请输入车辆匹配顺序" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="核算编号" prop="fdAccountingNumber">
              <el-input v-model="form.fdAccountingNumber" placeholder="请输入核算编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报价编号" prop="fdQuotationNumber">
              <el-input v-model="form.fdQuotationNumber" placeholder="请输入报价编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="核算类别" prop="fdAccountingCategory">
              <el-select v-model="form.fdAccountingCategory" placeholder="请选择核算类别">
                <el-option
                  v-for="dict in dict.type.accounting_category"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="过路费类别" prop="fdRoadTollCategory">
              <el-select v-model="form.fdRoadTollCategory" placeholder="请选择过路费类别">
                <el-option
                  v-for="dict in dict.type.toll_category"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车公里成本合计" prop="fdTotalCostPerVehicleKilometer">
              <el-input v-model="form.fdTotalCostPerVehicleKilometer" placeholder="请输入车公里成本合计" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="吨公里成本合计" prop="fdTotalCostPerTonneKilometer">
              <el-input v-model="form.fdTotalCostPerTonneKilometer" placeholder="请输入吨公里成本合计" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="立方成本合计" prop="fdTotalCostPerCubicMeter">
              <el-input v-model="form.fdTotalCostPerCubicMeter" placeholder="请输入立方成本合计" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="提货费" prop="fdPickUpFee">
              <el-input v-model="form.fdPickUpFee" placeholder="请输入提货费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="装车费" prop="fdLoadingFee">
              <el-input v-model="form.fdLoadingFee" placeholder="请输入装车费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="卸车费" prop="fdUnloadingFee">
              <el-input v-model="form.fdUnloadingFee" placeholder="请输入卸车费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="风险管理费率" prop="fdRiskManagementFeeRate">
              <el-input v-model="form.fdRiskManagementFeeRate" placeholder="请输入风险管理费率" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="调整系数" prop="fdTzxs">
              <el-input v-model="form.fdTzxs" placeholder="请输入调整系数" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="不含税报价" prop="fdTaxExcludedQuotation">
              <el-input v-model="form.fdTaxExcludedQuotation" placeholder="请输入不含税报价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="税率" prop="fdTaxRate">
              <el-input v-model="form.fdTaxRate" placeholder="请输入税率" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="税金" prop="fdTax">
              <el-input v-model="form.fdTax" placeholder="请输入税金" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="含税报价" prop="fdHsbj">
              <el-input v-model="form.fdHsbj" placeholder="请输入含税报价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="核算人" prop="fdAccountant">
              <el-input v-model="form.fdAccountant" placeholder="请输入核算人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="核算时间" prop="fdAccountingTime">
              <el-date-picker clearable
                v-model="form.fdAccountingTime"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择核算时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="fdRemark">
              <el-input v-model="form.fdRemark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
          ref="upload"
          :limit="1"
          accept=".xlsx, .xls"
          :headers="upload.headers"
          :action="upload.url + '?updateSupport=' + upload.updateSupport"
          :disabled="upload.isUploading"
          :on-progress="handleFileUploadProgress"
          :on-success="handleFileSuccess"
          :auto-upload="false"
          drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <organizationalSelect ref="organizationalSelect" @onSelected="onSelected"></organizationalSelect>

  </div>
</template>

<script>
import { listFreightQuotationAccounting, getFreightQuotationAccounting, delFreightQuotationAccounting, addFreightQuotationAccounting, updateFreightQuotationAccounting } from "@/api/ys/freightQuotationAccounting";
import {getToken} from "@/utils/auth";
export default {
  name: "FreightQuotationAccounting",
  dicts: ['toll_category','accounting_category'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 运费报价核算表格数据
      freightQuotationAccountingList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        fdOrderId: null,
        fdPlannedRouteNumber: null,
        fdPlannedRouteName: null,
        fdPlannedLicensePlateNumber: null,
        fdAccountingNumber: null,
        fdQuotationNumber: null,
      },
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "导入`freightQuotationAccounting`信息",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/ys/freightQuotationAccounting/importData"
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /*选择组织*/
    selectOrganization() {
      this.$refs['organizationalSelect'].show()
    },
    /*选择组织组件回调*/
    /*参数：组织信息*/
    onSelected(org) {
      this.form.fdOrganizationCode=org.gcdm
      this.form.fdOrganizationName=org.gcmc
    },
    /** 查询运费报价核算列表 */
    getList() {
      this.loading = true;
      listFreightQuotationAccounting(this.queryParams).then(response => {
        this.freightQuotationAccountingList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        fdSerialNum: null,
        fdOrganizationName: null,
        fdOrganizationCode: null,
        fdOrganizationCategory: null,
        fdOrganizationLevel: null,
        fdOrderId: null,
        fdOrderSource: null,
        fdPublishingUnit: null,
        fdSourceReleaseDate: null,
        fdExpectedArrivalDate: null,
        fdUrgencyLevelOfCargoSource: null,
        fdSourceDeparturePlace: null,
        fdDetailedDepartureAddress: null,
        fdDestinationOfCargoSource: null,
        fdDetailedDestinationAddress: null,
        fdWeightOfCargoSource: null,
        fdVolumeOfCargoSource: null,
        fdPlannedRouteNumber: null,
        fdPlannedRouteName: null,
        fdTransferAddress: null,
        fdPlannedRouteMileage: null,
        fdPlannedLicensePlateNumber: null,
        fdVehicleBarcode: null,
        fdLoadQuality: null,
        fdVehicleVolume: null,
        fdVehicleMatchingSequence: null,
        fdAccountingNumber: null,
        fdQuotationNumber: null,
        fdAccountingCategory: null,
        fdRoadTollCategory: null,
        fdTotalCostPerVehicleKilometer: null,
        fdTotalCostPerTonneKilometer: null,
        fdTotalCostPerCubicMeter: null,
        fdPickUpFee: null,
        fdLoadingFee: null,
        fdUnloadingFee: null,
        fdRiskManagementFeeRate: null,
        fdTzxs: null,
        fdTaxExcludedQuotation: null,
        fdTaxRate: null,
        fdTax: null,
        fdHsbj: null,
        fdAccountant: null,
        fdAccountingTime: null,
        fdRemark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加运费报价核算";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getFreightQuotationAccounting(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改运费报价核算";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateFreightQuotationAccounting(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addFreightQuotationAccounting(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除数据？').then(function() {
        return delFreightQuotationAccounting(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('ys/freightQuotationAccounting/export', {
        ...this.queryParams
      }, `freightQuotationAccounting_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "运费报价核算导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('ys/freightQuotationAccounting/importTemplate', {
      }, `运费报价核算模板.xlsx`)
    },
    /** 文件上传中处理 */
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    /** 文件上传成功处理 */
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    /** 提交上传文件 */
    submitFileForm() {
      this.$refs.upload.submit();
    },
  }
};
</script>
